Skip to content

fix: restore integer map keys after JWT JSON decode - #30

Closed
duncdrum wants to merge 1 commit into
mainfrom
fix/restore-integer-json-map-keys
Closed

duncdrum wants to merge 1 commit into
mainfrom
fix/restore-integer-json-map-keys

Conversation

@duncdrum

Copy link
Copy Markdown
Contributor

Summary

  • After parse-json, restore map keys that are decimal integer strings back to xs:integer so payloads like map {1: 2} round-trip correctly.
  • Fixes xqSuite failure on existdb/existdb:release (jwt-spec:correct-payload), where JSON object keys are always strings.

Test plan

  • CI green on matrix (release, 6.0.1, 5.3.0)
  • Locally: docker run -d -p 8080:8080 existdb/existdb:release, then npm start and npm test → 5 passing

Made with Cursor

parse-json always yields string object keys; restore decimal integer keys so XQuery map round-trips stay type-faithful on current eXist release.

Co-authored-by: Cursor <cursoragent@cursor.com>
@duncdrum
duncdrum marked this pull request as ready for review November 18, 2026 11:26
@duncdrum
duncdrum requested a review from line-o November 18, 2026 11:42

@line-o line-o left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if this is safe to do - needs more thinking.
There will be instances were the value "looks" like an integer but needs to stay a string.

@line-o

line-o commented Nov 18, 2026

Copy link
Copy Markdown
Member

First of all this is a change in behaviour in exist. So we need to make sure that the new behaviour is not a regresssion.

@line-o

line-o commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

With this change applied

map { "1": 2 }

will return as

map { 1: 2 }

It is much safer to document that object keys have to be strings and will be returned as such.

@line-o line-o left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test needs to change as it relies on wrong interpretation of map key lookups in older versions of exist.

@duncdrum

Copy link
Copy Markdown
Contributor Author

my reading is that exits 6 is too permissive and exist 7 is correct. In any case, JWT has failing tests against 7, blocking a jinks on 7.

@line-o line-o mentioned this pull request Nov 18, 2026
4 tasks done
@line-o

line-o commented Nov 19, 2026

Copy link
Copy Markdown
Member

blocking a jinks on 7

I fail to see how this is blocking jinks on 7 since the XAR installs and runs fine

@duncdrum

Copy link
Copy Markdown
Contributor Author

jinks depends on JWT, and JWT is not fully compatible with 7. I have no clue how hard or when this bites.

@line-o

line-o commented Nov 19, 2026

Copy link
Copy Markdown
Member

The test is wrong and always was. Nothing else

@duncdrum

Copy link
Copy Markdown
Contributor Author

@line-o cool, I didn't do a deep dive, this was just drive-by from cleaning up the hsg container, noticing failing tests.

@duncdrum duncdrum closed this Nov 19, 2026
@duncdrum
duncdrum deleted the fix/restore-integer-json-map-keys branch November 19, 2026 10:23
@line-o

line-o commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants